//
//  YCMineTableViewCell.m
//  YCVillageDoctor
//
//  Created by zhangxiaoliang on 2017/6/7.
//  Copyright © 2017年 zhangxiaoliang. All rights reserved.
//

#import "YCMineTableViewCell.h"
#import "YCMineModel.h"
@interface YCMineTableViewCell()
@property(nonatomic,strong) UIImageView *imageIcon;
@property(nonatomic,strong) UILabel *labelText;
@property(nonatomic,strong)UIImageView *imageArrow;
@property(nonatomic,strong)UILabel *labelPhone;
@end
@implementation YCMineTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        UIImageView *imageIcon = [[UIImageView alloc]init];
        self.imageIcon = imageIcon;
        imageIcon.contentMode = UIViewContentModeCenter;
        [self.contentView addSubview:imageIcon];
        
        
        UILabel *labelText = [[UILabel alloc]init];
        self.labelText = labelText;
        [self.contentView addSubview:labelText];
        labelText.font = [UIFont fontWithName:kFontLite size:16];
        UIImageView *imageArrow = [[UIImageView alloc]init];
        imageArrow.image = [UIImage imageNamed:@"圆角矩形-1-拷贝-3"];
        imageArrow.contentMode = UIViewContentModeCenter;
        self.imageArrow = imageArrow;
        [self.contentView addSubview:imageArrow];
        
        
        UILabel *labelPhone = [[UILabel alloc]init];
        self.labelPhone = labelPhone;
        labelPhone.text = @"400-656-2020";
        labelPhone.textAlignment = NSTextAlignmentRight;
        labelPhone.textColor = HexColor(0x3a79ea);
        labelPhone.hidden = YES;
        [self.contentView addSubview:labelPhone];
        
        
        //布局
        __weak __typeof(&*self)mySelf = self;
        [imageIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(mySelf.contentView.mas_left).mas_offset(20);
            make.centerY.mas_equalTo(mySelf.contentView.mas_centerY);
            make.width.mas_equalTo(30);
            make.height.mas_equalTo(30);
        }];
        
        
        [labelText mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(mySelf.contentView.mas_centerY);
            make.left.mas_equalTo(imageIcon.mas_right).mas_offset(20);
            make.width.mas_equalTo(200);
            make.height.mas_equalTo(30);
        }];
        
        
        [imageArrow mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(mySelf.contentView.mas_centerY);
            make.right.mas_equalTo(mySelf.contentView.mas_right).mas_offset(-15);
            make.width.mas_equalTo(30);
            make.height.mas_equalTo(30);
        }];
        
        
        [labelPhone mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(mySelf.contentView.mas_centerY);
            make.right.mas_equalTo(mySelf.contentView.mas_right).mas_offset(-15);
            make.width.mas_equalTo(200);
            make.height.mas_equalTo(30);
        }];
        
    }
    return self;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)setModel:(YCMineModel *)model
{
    _model = model;
    self.imageIcon.image = [UIImage imageNamed:model.imageName];
    self.labelText.text = model.labelTextStr;
    if (_isServiceHotline) {
        self.imageArrow.hidden = YES;
        self.labelPhone.hidden = NO;
    }
}

@end
